package com.wanli.agent.homepage;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.codingending.popuplayout.PopupLayout;
import com.google.gson.Gson;
import com.wanli.agent.R;
import com.wanli.agent.base.BaseActivity;
import com.wanli.agent.base.DataCallBack;
import com.wanli.agent.bean.DeviceUnifyBean;
import com.wanli.agent.bean.UserInfoBean;
import com.wanli.agent.homepage.model.HomePageModelImpl;
import com.wanli.agent.utils.SPManager;
import com.wanli.agent.widget.AppTitleBar;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MerchantIntoActivity extends BaseActivity {

    @BindView(R.id.title_bar)
    AppTitleBar titleBar;
    @BindView(R.id.ll_store_1)
    RelativeLayout llStore1;
    @BindView(R.id.ll_store_2)
    RelativeLayout llStore2;
    @BindView(R.id.ll_store_3)
    RelativeLayout llStore3;
    @BindView(R.id.ll_store_4)
    RelativeLayout llStore4;
    @BindView(R.id.ll_store_5)
    RelativeLayout llStore5;
    @BindView(R.id.tv_tips)
    TextView tvTips;
    private int channel_type;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_merchant_into);
        ButterKnife.bind(this);
//        initData();
        UserInfoBean userInfoBean = new Gson().fromJson(SPManager.getInstance().getUserInfoJson(), UserInfoBean.class);
        channel_type = userInfoBean.getData().getChannel_type();

        if (channel_type==2){
            //智能版
            llStore2.setVisibility(View.GONE);
            llStore3.setVisibility(View.GONE);
        }


    }

    public void initData() {
        new HomePageModelImpl().requestDeviceUnifyTypeReceived(new DataCallBack<DeviceUnifyBean>() {
            @Override
            public void onSuccessful(DeviceUnifyBean bean) {
                if (bean.getData() != null && bean.getData().size() > 0) {
                    DeviceUnifyBean.DataBean dataBean = bean.getData().get(0);
                    if (dataBean.getType_3_count() == 0 && dataBean.getType_6_count() == 0) {
                        llStore1.setVisibility(View.GONE);
                        llStore2.setVisibility(View.GONE);
                        llStore3.setVisibility(View.GONE);
                        tvTips.setVisibility(View.GONE);
                    } else {
                        llStore1.setVisibility(View.VISIBLE);
                        llStore2.setVisibility(View.VISIBLE);
                        llStore3.setVisibility(View.VISIBLE);
                        tvTips.setVisibility(View.VISIBLE);
                    }
                }
            }

            @Override
            public void onFailed(String msg, String code) {

            }
        });
    }

    @OnClick({R.id.ll_store_1, R.id.ll_store_2, R.id.ll_store_3, R.id.ll_store_4, R.id.ll_store_5})
    public void onViewClicked(View view) {
         Intent intent;
        switch (view.getId()) {
            case R.id.ll_store_1:
                intent = new Intent(mActivity, StoreDataActivity.class);
                intent.putExtra("type", "1");
                startActivity(intent);
                break;
            case R.id.ll_store_2:
                intent = new Intent(mActivity, StoreDataActivity.class);
                intent.putExtra("type", "2");
                startActivity(intent);
                break;
            case R.id.ll_store_3:
                intent = new Intent(mActivity, StoreDataActivity.class);
                intent.putExtra("type", "3");
                startActivity(intent);
                break;
            case R.id.ll_store_4:
                intent = new Intent(mActivity, EBankStoreDataActivity.class);
                intent.putExtra("type", "1");
                intent.putExtra("quick_income", 2);
                startActivity(intent);
                break;
            case R.id.ll_store_5:
                intent = new Intent(mActivity, EBankStoreDataActivity.class);
                intent.putExtra("type", "3");
                intent.putExtra("quick_income", 2);
                startActivity(intent);
                break;
        }
    }

}
